# -*- coding:utf-8 -*-
"""
@author:Mr.头发又黑又长
@file: middleware.py
@time: 2020/05/22
"""

# 跨域问题中间

from django.utils.deprecation import MiddlewareMixin


class CrossDomain(MiddlewareMixin):
    def process_response(self, request, response):
        # 允许你的域名来获取我的数据
        response['Access-Control-Allow-Origin'] = "*"

        # 允许你携带Content-Type请求头
        response['Access-Control-Allow-Headers'] = "Content-Type,x-requested-with,authorisation,Access-Token"

        # 允许你发送DELETE,PUT
        response['Access-Control-Allow-Methods'] = "DELETE,PUT,PATCH,POST,PUT,GET"

        return response
